home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _533B598138B841DEAFEFB2BD12D321F2 < prev    next >
Text File  |  2005-03-08  |  1KB  |  71 lines

  1. //sky vertex shader:
  2. //moves texture coordinates with time
  3. //generates textures coordinates for 2 layers of sky
  4.  
  5. //Luke Lenhart
  6. //(C)2004-2005 Digipen Institute of Technology
  7.  
  8. //brightness of sky
  9. float4 skyColor;
  10.  
  11. //scale of cloud size
  12. float scale;
  13.  
  14. //alpha value of layer
  15. float alpha;
  16.  
  17. //world,view,projection transform
  18. float4x4 matWorldViewProj;
  19.  
  20. //current time (in seconds) since whenever
  21. float curTime;
  22.  
  23. //shader input
  24. struct VS_INPUT
  25. {
  26.     float4 Pos : POSITION;
  27.     float2 Tex0 : TEXCOORD0;
  28. };
  29.  
  30. //shader output
  31. struct VS_OUTPUT
  32. {
  33.     float4 Pos : POSITION;
  34.     float4 Color : COLOR;
  35.     float2 Tex0 : TEXCOORD0;
  36.     float2 Tex1 : TEXCOORD1;
  37. };
  38.  
  39. //shader code
  40. VS_OUTPUT VShader(VS_INPUT In)
  41. {
  42.     VS_OUTPUT Out;
  43.     
  44.     //calc transformed position
  45.     Out.Pos=mul(matWorldViewProj,In.Pos);
  46.     
  47.     float2 postxt=float2(In.Pos.x,In.Pos.y);
  48.     Out.Tex0=postxt*0.75f+float2(curTime*.038,curTime*.007);
  49.     Out.Tex1=scale*(postxt+float2(curTime*-.0127,curTime*.011));
  50.     
  51.     //make vert color
  52.     Out.Color=skyColor;
  53.     Out.Color.a=1.0f;
  54.     
  55.     //if z is near 0, fade it out
  56.     if (In.Pos.z<=0.0f)
  57.     {
  58.         Out.Color.a=0.0f;
  59.     }
  60.     else if (In.Pos.z<0.05f)
  61.     {
  62.         Out.Color.a=0.35f;    
  63.     }
  64.     
  65.     //apply alpha
  66.     Out.Color.a*=alpha;
  67.  
  68.     //spit out the results
  69.     return Out;
  70. }
  71.